<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>后台系统-管理员</title>
  <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body class="layui-layout-body">
	
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo">管理员系统</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <li class="layui-nav-item">&nbsp;&nbsp;&nbsp;控制台</li>
    </ul>
	
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item" id="username"></li>
      <li class="layui-nav-item"><a href="javascript:;" onclick="logout()">退出</a></li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree">
        <li class="layui-nav-item">
          <a href="javascript:;">库存管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;" onclick="change('medInSto')">药品入库</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">信息浏览</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;" onclick="change('medMsg')">药品信息</a></dd>
            <dd><a href="javascript:;" onclick="change('facMsg')">药厂信息</a></dd>
            <dd><a href="javascript:;" onclick="change('buyMsg')">采购人信息</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
			<a href="javascript:;">出入库记录</a>
			<dl class="layui-nav-child">
			  <dd><a href="javascript:;" onclick="change('outSto')">出库记录</a></dd>
			  <dd><a href="javascript:;" onclick="change('inSto')">入库记录</a></dd>
			</dl>
		</li>
        <li class="layui-nav-item">
		  <a href="javascript:;">药品管理</a>
		  <dl class="layui-nav-child">
			<!-- <dd><a href="javascript:;" onclick="change('addMed')">增加药品</a></dd> -->
			<dd><a href="javascript:;" onclick="change('delAndUpdMed')">添加&修改&删除</a></dd>
		  </dl>
        </li>
        
        <li class="layui-nav-item">
		  <a href="javascript:;">药厂管理</a>
		  <dl class="layui-nav-child">
			<!-- <dd><a href="javascript:;" onclick="change('addFac')">增加药厂</a></dd> -->
			<dd><a href="javascript:;" onclick="change('delAndUpdFac')">添加&修改&删除</a></dd>
		  </dl>
        </li>
        
        <li class="layui-nav-item">
		  <a href="javascript:;">采购人管理</a>
		  <dl class="layui-nav-child">
			<!-- <dd><a href="javascript:;" onclick="change('addBuyer')">增加采购人</a></dd> -->
			<dd><a href="javascript:;" onclick="change('delAndUpdBuyer')">添加&修改&删除</a></dd>
		  </dl>
        </li>
        
        <li class="layui-nav-item">
		  <a href="javascript:;">取药员管理</a>
		  <dl class="layui-nav-child">
			<!-- <dd><a href="javascript:;" onclick="change('addUser')">添加取药员</a></dd> -->
			<dd><a href="javascript:;" onclick="change('delUser')">添加&删除</a></dd>
		  </dl>
        </li>
      </ul>
    </div>
  </div>
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
		<iframe src="welcome.html" frameborder="0" id="mainAdmin" style="width: 100%; height: 600px;"></iframe> 
	</div>
  </div>
  
  <div class="layui-footer" style="text-align: center;color: #009E94;">
    <!-- 底部固定区域 -->
    @ 医院药品管理系统2.0
  </div>
  
</div>

<script src="layui/layui.js"></script>
<script src="js/jquery-3.4.1.js"></script>
<script>
//JavaScript代码区域
layui.use('element', function(){
  var element = layui.element;
});

function change(title){
	let url=title+".html";
	$('#mainAdmin').attr('src',url);
}

let userName=sessionStorage.getItem("userName");
console.log(userName);
$('#username').text(userName);

function logout(){
	$.ajax({
		type:"get",
		url:"http://localhost:8081/user/logout",
		async:true,
		contentType:"application/json;charset=UTF-8",
		xhrFields: {
			withCredentials: true
		},
		success:function(res){
			//alert(res);
			if(res=="success"){
				window.location.href = 'login.html';
			}
		}
	});
	sessionStorage.clear();
}

</script>

</body>
</html>